<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Carson</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script language="javascript">

        function setText(text){
             document.getElementById("text").innerHTML = text;
        }

        // js 调用 Android,
        function callAsLoginAction(){
            //无返回值
            window.AndroidJsBridge.callAsLogin("js-text");
        }

        function callAsTokenStringAction(){
            console.log("---------callAsTokenStringAction---------");
            // 由于对象映射，所以调用AndroidJsBridge对象等于调用Android映射的对象
            // js调用了android中的callAsTokenString方法  有一个返回值,类型 String
            var jsonString = window.AndroidJsBridge.callAsTokenString(); // {"token":"token","invitecode":"invitecode"}
            //setText(jsonString)

            //var obj = eval(jsonString);
            var obj = JSON.parse(jsonString); //由JSON字符串转换为JSON对象
            setText(obj.token);//token
         }

        //  获取不到
        function callAsTokenJsonAction(el){
            console.log("---------callAsTokenJsonAction---------");
            // js调用了android中的callAsTokenJson方法  有返回值 2个 ,JSONObject
            //var obj = window.AndroidJsBridge.callAsTokenJson();//
            //var objj  = eval(obj) ;
            //setText(obj.token) //undefined

            eval("var obj = " + window.AndroidJsBridge.callAsTokenJson());
            //alert('typeof:'+typeof(obj));
            alert('token:'+obj.token);
            //setText(obj.nameValuePairs)
            //alert(obj.token);
            //setText(obj.token)

            //var jsonStr = JSON.stringify(obj);
            //alert(jsonStr);
            //setText(jsonStr)
        }

<!--        function callAsTokenJsonEvalAction(){-->
<!--            window.AndroidJsBridge.callAsTokenJsonEval();-->
<!--        }-->
<!--        fun callTokenJsonResult(obj){-->
<!--            //eval(obj)-->
<!--           // setText(obj.token)-->
<!--            //alert(obj)-->
<!--            //var jsonStr = JSON.stringify(obj);-->
<!--            //setText(jsonStr)-->
<!--        }-->


        function callAsStringAction(){
            // alert("来自callAsRootAction信息：");
            // 由于对象映射，所以调用test对象等于调用Android映射的对象  传递字符串
            //window.AndroidJsBridge.callAsString("{\"id\":\"16\",\"b\":1}");
            window.AndroidJsBridge.callAsString("{\"token\":\"16\",\"invitecode\":\"1\"}");
        }

       // function callAndroidAction(){
       //     /*约定的url协议为：js://webview?arg1=111&arg2=222*/
       //     document.location = "js://webview?arg1=111&arg2=222";
       //  }




       function isInstall(){
             window.location.href ="echain://huanyi/page?type=PayDataActivity&orderID=127548846&amount=1.11&currencyID=39&currencySymbol=%C2%A5&orderType=2&sanCode=SARO&is_saro=1&saro_rate=371.0&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDU3NzA2MDQsInVzZXJJZCI6IjQ4MDQwNTI4NDE4Mzg3MTQ4OCIsInN5c1R5cGUiOjB9.XFd2BpuwKeFm6vmZcS3fzprliRfMYKS0bmSdT9LBoBI"; //schema链接或者universal link
              //window.location = 'https://www.echainbuy.com'; //schema链接或者universal link
             window.setTimeout(function () {
                window.location.href = "https://www.echainbuy.com/app/echain-release.apk"; //android 下载地址
             }, 500);

       }

        //活动 URL
       function goBillActivityAction(){
          window.location.href="echain://huanyi/activity?type=billActivity";
          //window.location.href="https://www.echainbuy.com/activity?type=billActivity";
       }

       //支付页
       function goPayDataActivityAction(){
           //window.location.href="echain://huanyi/page?type=PayDataActivity&orderID=127549093&amount=1.11&currencyID=39&currencySymbol=¥&orderType=2&sanCode=SARO&is_saro=1&saro_rate=371.0&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDYwNDE1NjAsInVzZXJJZCI6IjQ4MDQwNTI4NDE4Mzg3MTQ4OCIsInN5c1R5cGUiOjB9.ykBF8iokTQe0OtATBpmtj_1eB3jv0Btjd10ICJljXW4"
           //window.location.href="https://www.echainbuy.com/page?type=PayDataActivity&orderID=127549093&amount=1.11&currencyID=39&currencySymbol=¥&orderType=2&sanCode=SARO&is_saro=1&saro_rate=371.0&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDYwNDE1NjAsInVzZXJJZCI6IjQ4MDQwNTI4NDE4Mzg3MTQ4OCIsInN5c1R5cGUiOjB9.ykBF8iokTQe0OtATBpmtj_1eB3jv0Btjd10ICJljXW4"

           window.location.href="echain://huanyi/openApp?type=PayDataActivity&orderID=127549163&amount=1&currencyID=39&currencySymbol=¥&orderType=2&sanCode=SARO&is_saro=1&saro_rate=371.0&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDY5ODg2NjUsInVzZXJJZCI6IjQ4MDQwNTI4NDE4Mzg3MTQ4OCIsInN5c1R5cGUiOjF9.HHwHyltDl0KevVEh8yUEcnabgA5_Cs_B2PtKfa_Z700"
           //window.location.href="https://www.echainbuy.com/openApp?type=PayDataActivity&orderID=127549163&amount=1&currencyID=39&currencySymbol=¥&orderType=2&sanCode=SARO&is_saro=1&saro_rate=365&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDY1MzI5MDgsInVzZXJJZCI6IjQ4MDQwNTI4NDE4Mzg3MTQ4OCIsInN5c1R5cGUiOjB9.NMsPshPp5Nr6DTUzntgAMxpUJfegS54IVo_WiwZDT_c"
       }

        // 订单详情页
       function goOrderDataActivityAction(){
            window.location.href="echain://huanyi/openApp?type=OrderDataActivity&orderID=127549101&isSaroRate=371.0&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDY5ODg2NjUsInVzZXJJZCI6IjQ4MDQwNTI4NDE4Mzg3MTQ4OCIsInN5c1R5cGUiOjF9.HHwHyltDl0KevVEh8yUEcnabgA5_Cs_B2PtKfa_Z700";
            //window.location.href="https://www.echainbuy.com/openApp?type=OrderDataActivity&orderID=127549101&isSaroRate=371.0&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDY1MzI5MDgsInVzZXJJZCI6IjQ4MDQwNTI4NDE4Mzg3MTQ4OCIsInN5c1R5cGUiOjB9.NMsPshPp5Nr6DTUzntgAMxpUJfegS54IVo_WiwZDT_c";
       }
        //售后详情页
        function goAfterSaleDetailActivityAction(){
          window.location.href="echain://huanyi/openApp?type=AfterSaleDetailActivity&afterSaleId=254&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDcwNzMxNjcsInVzZXJJZCI6IjQ4MDQwNTI4NDE4Mzg3MTQ4OCIsInVuaW9uVXNlcklkIjoiQXhWaTliRlNQZXZ6bm5kMmppM0FnUCIsInN5c1R5cGUiOjF9.JH9JjfN6cncaXSNGEdnrEEh2Y-4uSUfj40no_ZSZtI0";
          //window.location.href="https://www.echainbuy.com/openApp?type=AfterSaleDetailActivity&afterSaleId=254&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDY1MzI5MDgsInVzZXJJZCI6IjQ4MDQwNTI4NDE4Mzg3MTQ4OCIsInN5c1R5cGUiOjB9.NMsPshPp5Nr6DTUzntgAMxpUJfegS54IVo_WiwZDT_c";
       }
       //打开 APP
       function openAppAction(){
          window.location.href="echain://huanyi/openApp";
          //window.location.href="https://www.echainbuy.com/openApp";
       }

    </script>
</head>
<body>
<!--//点击按钮则调用callAndroid函数-->
<button type="button" value="按钮1" name="按钮1" id="button1" onclick="callAsLoginAction()">按钮1
    callAsLoginAction
</button>
</br></br>

<button type="button" value="按钮2" name="按钮2" id="button2" onclick="callAsTokenStringAction()">按钮2
    callAsTokenStringAction
</button>
</br></br>


<button type="button" value="按钮3" name="按钮3" id="button3" onclick="callAsTokenJsonAction()">按钮3
    callAsTokenJsonAction
</button>
</br></br>


<button type="button" value="按钮4" name="按钮4" id="button4" onclick="callAsTokenJsonEvalAction()">按钮4
    callAsTokenJsonEvalAction
</button>
</br></br>

<button type="button" value="按钮5" name="按钮5" id="button5" onclick="callAsStringAction()">按钮5
    callAsStringAction
</button>
</br></br>

<button type="button" value="按钮11" name="按钮11" id="button11" onclick="goBillActivityAction()">按钮11
    goBillActivityAction
</button>
</br></br>

<button type="button" value="按钮12" name="按钮12" id="button12" onclick="goPayDataActivityAction()">按钮12
    goPayDataActivityAction
</button>
</br></br>

<button type="button" value="按钮13" name="按钮13" id="button13" onclick="goOrderDataActivityAction()">按钮13
    goOrderDataActivityAction
</button>
</br></br>

<button type="button" value="按钮14" name="按钮14" id="button14" onclick="goAfterSaleDetailActivityAction()">按钮14
    goAfterSaleDetailActivityAction
</button>
</br></br>

<button type="button" value="按钮15" name="按钮15" id="button15" onclick="openAppAction()">按钮15
    openAppAction
</button>
</br></br>

<span id="text">text</span></br>
</br></br>

</body>
</html>